package com.db4o.internal.odbgen;



public class StringUtils {
	/**
	 * Returns a new line.
	 */
	public static String newLine() {
		return System.getProperty("line.separator");
	}

	/**
	 * Returns a string representing the specified number of tabs.
	 */
	public static String tabs(int tabs) {
		StringBuilder res = new StringBuilder();
		for(int i=0; i<tabs; i++)
			res.append('\t');
		return res.toString();
	}
	
	/**
	 * Adds quotes to the received string, if necessary.
	 * Example: 
	 * book -> "book"
	 * "book" -> "book"
	 * @param content
	 * @return The quoted string
	 */
	public static String addQuotes(String content) {
		StringBuilder res = new StringBuilder();
		if(!content.substring(0, 1).equals("\"")){
			res.append("\"");
		}
		res.append(content);
		if(!content.substring(content.length()-1, content.length()).equals("\"")){
			res.append("\"");
		}
		return res.toString();
	}

	/**
	 * Receives a name and returns its uppercase version.
	 * Example: name -> Name
	 * @param field
	 * @return
	 */
	public static String buildUppercaseName(String name) {
		StringBuilder res = new StringBuilder();
		res.append(name.substring(0, 1).toUpperCase());
		res.append(name.substring(1, name.length()));
		return res.toString();
	}

	
}
